//
//  ZuoJBaseController.swift
//  Tanenbaum_blog
//
//  Created by Tanenbaum on 15/7/28.
//  Copyright © 2015年 GZJ. All rights reserved.
//

import UIKit

class ZuoJBaseController: UITableViewController,VisitorLoginViewDelegate{

 
       var userLogin = UserAccount.userLogon
    

       var visitorView: ZuoJVisitorLoginView?
    
    override func loadView() {
        
        userLogin ? super.loadView() : setUpVisitorView()
    }

    
    //设置未登录界面
    private func setUpVisitorView() {
        
        visitorView = ZuoJVisitorLoginView()
        visitorView?.delegate = self
        view = visitorView
       
        
        
        
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: "visitorLoginViewWillRegister")
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", style: UIBarButtonItemStyle.Plain, target: self, action: "visitorLoginViewWillLogin")
        
        
    }
    
    
    // MARK: - VisitorLoginViewDelegate
    func visitorLoginViewWillLogin() {
        
        
        let nav = UINavigationController(rootViewController: OAuthViewController())
        presentViewController(nav, animated:true,completion: nil)
    }
    
    func visitorLoginViewWillRegister() {
        print("注册")
    }
}
